import * as THREE from 'three'
// 添加火灾半球体类
export class FireBall {
  constructor(scene, center) {
    this.scene = scene
    this.center = center
    this.nowMesh = {}
    this.nowScale = 0
    this.init()
  }
  init() {
    const geometry = new THREE.SphereGeometry(25, 32, 16, 0, Math.PI * 2, 0, Math.PI / 2)
    const material = new THREE.MeshStandardMaterial({ color: 0xf4790d, wireframe: false, side: THREE.DoubleSide, depthTest: false, })
    const hemisphere = new THREE.Mesh(geometry, material)
    this.nowMesh = hemisphere
    hemisphere.position.set(this.center.x, 0, this.center.z)
    this.scene.add(hemisphere)
    this.nowMesh.scale.set(0, 0, 0)
  }

  clear() {
    this.nowMesh.material.dispose()
    this.nowMesh.geometry.dispose()
    this.scene.remove(this.nowMesh)
  }
  onTick(t) {
    if (this.nowScale < 1) {
      this.nowScale += 0.01
      this.nowMesh.scale.set(this.nowScale, this.nowScale, this.nowScale)
    } else {
      this.nowScale = 0
      this.nowMesh.scale.set(0, 0, 0)
    }
  }
}